<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/include/TagLib.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb18030">
<meta name="save" content="history">
<title>QQ邮箱 - 收件箱</title>
<link rel="stylesheet" type="text/css" href="<c:url value='index_files/comm20100f0f4f.css' />">
<link rel="stylesheet" type="text/css" href="<c:url value='index_files/getcss.css' />">
<link rel="stylesheet" type="text/css" href="<c:url value='index_files/addr0dfb5a.css' />">
<script language="javascript" src="<c:url value='/js/jquery-1.4.2.min.js' />"></script>
<script language="javascript" src="<c:url value='/js/Pub.js' />"></script>
<style type="text/css">
.mysidebar {
	right: 10px;
	float: right;
	top: 35px;
	padding: 10px 8px 20px 8px;
	width: 164px;
	_width: 174px;
	height: auto;
}

.mailcontainer {
	min-width: 560px;
	margin-right: 186px;
	margin-top: 10px;
	position: relative;
	zoom: 1;
}

.list_body {
	min-width: 780px;
}

u {
	outline: medium none;
}

.tbody {
	overflow-x: hidden;
	_overflow-y: visible;
}

.talk {
	display: block;
	font: normal 12px Verdana;
	text-decoration: none;
	clear: both;
	border-left: none;
	border-right: none;
	padding: 8px 0 3px 9px;
	border-bottom-width: 2px;
	border-top: none;
}

.talk b {
	font-size: 14px
}

.toarea .F,.toarea .M {
	border-bottom-width: 1px;
}

.toarea .bd {
	border-bottom-width: 1px;
	border-top: 0 none;
	border-left: 0 none;
	border-right: 0 none;
}

.talk label {
	cursor: pointer;
}

.jumpmenusdjust {
	_padding-top: 8px;
}

input.s2bg {
	background:
		url(https://res.mail.qq.com/zh_CN/htmledition/images/newicon/shop087169.gif)
		0 0 no-repeat;
	border: 0;
	padding: 0;
	width: 16px;
	height: 14px;
	_vertical-align: middle;
}

.rssbg {
	background:
		url(https://res.mail.qq.com/zh_CN/htmledition/images/dy/dy_center083516.png)
		no-repeat 0 0px;
	width: 12px;
	height: 14px;
	padding: 0;
	border-width: 0;
}

.ico_rssObj {
	margin: 2px 0 0 -15px;
	position: absolute;
}

table.i td.ab {
	padding-top: 0;
	padding-bottom: 2px;
}

.importantmail {
	position: relative;
	margin-right: 5px;
	padding: 0 5px 2px; *
	padding: 2px 5px 0;
	border-radius: 2px;
	color: #fff;
	font-weight: normal;
}

.importantmail .arrow {
	_display: none;
	position: absolute;
	right: -3px;
	top: 50%;
	margin-top: -3px;
	border-width: 3px 0 3px 3px;
	border-style: dashed dashed dashed solid;
	border-color: transparent transparent transparent #e5e5e5;
	width: 0;
	height: 0;
	font-size: 0;
	line-height: 0;
}

.F .importantmail {
	background-color: #e5e5e5;
	color: #666;
}

.M .importantmail {
	background-color: #e5e5e5;
	color: #bbb;
}

.M .importantmail .arrow {
	border-left-color: #e5e5e5;
}
.active{
	font-weight:bold;
}
@media all and (-webkit-min-device-pixel-ratio:10000) , not all and
	(-webkit-min-device-pixel-ratio:0) {
	.importantmail .arrow {
		display: none;
	}
}
</style>
<script language="javascript">
	//邮件详细
	function queryMailInfo(id){
		  //2草稿箱,3已发送进入写信,其他进入详细页
	      if("${tblMailDetail.state}"=="2" || "${tblMailDetail.state}"=="3"){
	      	 location.href="<c:url value='/writeEmail.do' />?idMailDetail="+id;
	      }else{
		  	location.href="<c:url value='/queryMailInfo.do' />?idMailDetail="+id+"&pageNo=${page.currentPageNo}&state=${tblMailDetail.state}&queryStr=${queryStr}";
		  }
	}
	//跳转
	function skip(){
		 var pageNo=$('#pageNo_up').val()==""?$('#pageNo_down').val():$('#pageNo_up').val();
		 var idCompanyType="${idCompanyType}";
		 var idCompany = "${idCompany}";
   		 var idContactPerson = "${idContactPerson}";
		 if(trimSpace(pageNo)==''){
		 	alert("页数不能为空！");
		 	return;
		 }
	     if(!isNumber(pageNo,1)){
	     	alert("数字格式有误！");
	     	return;
	     }
		 if(parseInt("${page.totalPageCount}",10)>=parseInt(pageNo,10)){
		 	location.href="<c:url value='/listMailbox.do' />?pageNo="+pageNo+"&state=${tblMailDetail.state}&idCompany="+idCompany+"&idContactPerson="+idContactPerson+"&idCompanyType="+idCompanyType+"&queryStr=${queryStr}";
		 }else{
		 	alert("页数超出，请按正确输入！");
		 }
	}
	//下一页
	function down(pageNo){
	    var idCompanyType="${idCompanyType}";
		var idCompany = "${idCompany}";
   		var idContactPerson = "${idContactPerson}";
		location.href="<c:url value='/listMailbox.do' />?pageNo="+pageNo+"&state=${tblMailDetail.state}&idCompany="+idCompany+"&idContactPerson="+idContactPerson+"&idCompanyType="+idCompanyType+"&queryStr=${queryStr}";
	}
	//上一页
	function up(pageNo){
		var idCompanyType="${idCompanyType}";
		var idCompany = "${idCompany}";
   		var idContactPerson = "${idContactPerson}";
		location.href="<c:url value='/listMailbox.do' />?pageNo="+pageNo+"&state=${tblMailDetail.state}&idCompany="+idCompany+"&idContactPerson="+idContactPerson+"&idCompanyType="+idCompanyType+"&queryStr=${queryStr}";
	}
	//删除/彻底删除/全部标记为已读
	function operatMailDetail(state,mailsign){
		var len=$('input[name="chk"]:checked').length;
   		if(len==0){
   			alert("请选择要操作的数据！");
   		}else{
   			var arr=new Array();
   			for(var i=0;i<$('input[name="chk"]:checked').length;i++){
	   			arr.push($('input[name="chk"]:checked').eq(i).val());
   			}
   			var id=arr.join(",");
		    var idCompanyType="${idCompanyType}";
			var idCompany = "${idCompany}";
	   		var idContactPerson = "${idContactPerson}";
   			location.href="<c:url value='/saveMailDetail.do' />?pageNo=${page.currentPageNo}&state="+state+"&idMailDetails="+id+"&curstate=${tblMailDetail.state}&mailSign="+mailsign+"&idCompany="+idCompany+"&idContactPerson="+idContactPerson+"&idCompanyType="+idCompanyType+"&queryStr=${queryStr}";
   		}
	}
	//标志为/移动到
	function operatSelectMailDetail(obj,type){
		var len=$('input[name="chk"]:checked').length;
   		if(len==0){
   			alert("请选择要操作的数据！");
   		}else{
   		    if(type==1){
	   			var mailsign=$(obj).val();
	   			if(mailsign!=''){
		   			var arr=new Array();
		   			for(var i=0;i<$('input[name="chk"]:checked').length;i++){
			   			arr.push($('input[name="chk"]:checked').eq(i).val());
		   			}
		   			var id=arr.join(",");
		   			var idCompanyType="${idCompanyType}";
					var idCompany = "${idCompany}";
			   		var idContactPerson = "${idContactPerson}";
		   			location.href="<c:url value='/saveMailDetail.do' />?pageNo=${page.currentPageNo}&mailSign="+mailsign+"&idMailDetails="+id+"&curstate=${tblMailDetail.state}&idCompany="+idCompany+"&idContactPerson="+idContactPerson+"&idCompanyType="+idCompanyType+"&queryStr=${queryStr}";
	   			}
   			}else{
   				var state=$(obj).val();
	   			if(state!=''){
		   			var arr=new Array();
		   			for(var i=0;i<$('input[name="chk"]:checked').length;i++){
			   			arr.push($('input[name="chk"]:checked').eq(i).val());
		   			}
		   			var id=arr.join(",");
		   			var idCompanyType="${idCompanyType}";
					var idCompany = "${idCompany}";
			   		var idContactPerson = "${idContactPerson}";
		   			location.href="<c:url value='/saveMailDetail.do' />?pageNo=${page.currentPageNo}&state="+state+"&idMailDetails="+id+"&curstate=${tblMailDetail.state}&idCompany="+idCompany+"&idContactPerson="+idContactPerson+"&idCompanyType="+idCompanyType+"&queryStr=${queryStr}";
	   			}
   			}
   		}
	}
	function forwardingMail(){
		var len=$('input[name="chk"]:checked').length;
   		if(len==0){
   			alert("请选择要操作的数据！");
   		}else if(len==1){
   			var id;
   			for(var i=0;i<$('input[name="chk"]:checked').length;i++){
	   			id = $('input[name="chk"]:checked').eq(i).val();
   			}
   			location.href="<c:url value='/intoForwardingMail.do' />?idMailDetail="+id;
   		}else{
   			alert("抱歉，系统暂时只支持转发一封邮件！");
   		}
	}
   //是否选中复选框
   function check_all(obj){
	   if($(obj).attr("checked")){
		   $('input[name="chk"]').attr("checked",true);
	   }else{
		   $('input[name="chk"]').attr("checked",false);
	   }
   }
   //全部
   function checkAll(){
   	 $('input[name="chk"]').attr("checked",true);
   }
   //无
   function checkNone(){
   	 $('input[name="chk"]').attr("checked",false);
   }
   //未读/已读 1已读标志，0未读标志
   function checkRead(mailsign){
   		var len=$('input[name="chk"]:checked').length;
   		if(len==0){
   			alert("请选择要操作的数据！");
   			return;
   		}
	   	var arr=new Array();
		for(var i=0;i<$('input[name="chk"]:checked').length;i++){
	 		arr.push($('input[name="chk"]:checked').eq(i).val());
		}
		var id=arr.join(",");
		var idCompanyType="${idCompanyType}";
		var idCompany = "${idCompany}";
	 	var idContactPerson = "${idContactPerson}";
		location.href="<c:url value='/saveMailDetail.do' />?pageNo=${page.currentPageNo}&mailSign="+mailsign+"&idMailDetails="+id+"&curstate=${tblMailDetail.state}&idCompany="+idCompany+"&idContactPerson="+idContactPerson+"&idCompanyType="+idCompanyType+"&queryStr=${queryStr}";
   }
   //查询联系人
   function queryPerson(obj){
   	var val=$(obj).val();
	if(val!=""){
		var queryparam ={
			'idCompanyType':val
			};
		$.ajax({
			type: "POST", 
			url:"<c:url value='/queryCommPerson.do' />",
			async:true,
			data:queryparam,
			success:
			function(data) {
				if(data=="false"){
				    alert("操作失败！");
				 }else{
				    $('#per').html(data);
				 }
			}
		 });
	}else{
 		$('#per').html("");
	}
	//查询授权限邮箱
	queryMail(val,'','');
   }
   //查询授权限邮箱
   function queryMail(idCompanyType,idCompany,idContactPerson){
	   location.href="<c:url value='/listMailbox.do' />?pageNo=1&state=${tblMailDetail.state}&idCompany="+idCompany+"&idContactPerson="+idContactPerson+"&idCompanyType="+idCompanyType;
   }
   //显示该公司下的联系人
   function showContact(idObj){
   		var status = $("."+idObj).css("display");
   		if(status=="none"){
   			$("."+idObj).show();
   		}else{
   			$("."+idObj).hide();
   		}
   }
   //初始化查询联系人
   function initQueryPerson(obj){
   	var val=obj;
	if(val!=""){
		var queryparam ={
			'idCompanyType':val
			};
		$.ajax({
			type: "POST", 
			url:"<c:url value='/queryCommPerson.do' />",
			async:true,
			data:queryparam,
			success:
			function(data) {
				if(data=="false"){
				    alert("操作失败！");
				 }else{
				    $('#per').html(data);
				 }
			}
		 });
	}else{
 		$('#per').html("");
	}
   }
   //初始化显示该公司下的联系人
   function initShowContact(){
   		var idObj = "c${idCompany}";
   		var idContactPerson = "t${idContactPerson}";
   		var status = $("."+idObj).css("display");
   		if(status=="none"){
   			$("."+idObj).show();
   		}else{
   			$("."+idObj).hide();
   		}
   		
   		//公司高亮
   	    $("span[class='active']").removeAttr("class");
        var idCompany = "${idCompany}";
   	    if(idCompany!=null&&idCompany!=""){
	  		$("#cp"+idCompany).addClass("active");
	    }
   		$("#"+idContactPerson).addClass("active"); 
   }
   function init(){
   		var idCompany = "${idCompany}";
   		var idCompanyType = "${idCompanyType}";
   		
   		if(idCompany!=null&&idCompany!=""){
   			initQueryPerson(idCompanyType);
   			$("#companyType").val(idCompanyType);
   			setTimeout(initShowContact,50);
   		}
   }
   function activeSpan(obj){
	   $("span[class='active']").removeAttr("class");
	   $(obj).addClass("active"); 
   }
   //加载html控件
   $(function($){
      var idCompanyType="${idCompanyType}"; 
   	  initQueryPerson(idCompanyType);
   	  init();
   });
</script>
</head>
<body class="tbody" id="list">
	<div class="list_body">
		<div class="mailcontainer" id="qqmail_mailcontainer">
			<div class="txt_title">
				<c:choose>
					<c:when test="${tblMailDetail.state==1}">收件箱</c:when>
					<c:when test="${tblMailDetail.state==2}">草稿箱</c:when>
					<c:when test="${tblMailDetail.state==3}">已发送</c:when>
					<c:when test="${tblMailDetail.state==4}">已删除</c:when>
					<c:when test="${tblMailDetail.state==5}">垃圾箱</c:when>
				</c:choose>
				<span id="_ut" class="f_size normal black"> 
					(共 <span id="_ut_c">${page.totalCount}</span>
						封<span id="_ua" style="display: none;">，其中 <span id="_ur" style="display: none;"><a href="#" class="green">未读邮件</a><span id="_ur_c">0</span>封</span></span>)
				</span>
			</div>
			<form id="frm" name="frm" method="post" target="actionFrame">
				<input type="hidden" name="folderid" value="1">
				<input type="hidden" name="s" value="maillist">
				<input type="hidden" name="sid" value="qCeafiLqHJ6BcWEx">
				<input type="hidden" name="Fun" value="Del">
				<input name="srcfolderid" type="hidden" value="1">
				<input name="destfolderid" type="hidden">
				<input name="status" type="hidden">
				<input name="isspam" type="hidden">
				<input name="flag" type="hidden">
				<input name="mailaction" type="hidden">
				<input name="confirm" type="hidden">
				<input name="addr" type="hidden">
				<input name="nick" type="hidden">
				<input name="destfolder" type="hidden">
				<input name="t" type="hidden">
				<input name="loc" type="hidden">
				<input name="foldername" type="hidden">
				<input name="reporttype" type="hidden">
				<div class="toolbg toolbgline toolheight nowrap" style="">
					<div class="right">
						${page.currentPageNo}/${page.totalPageCount}页&nbsp;
						<c:if test="${page.currentPageNo!=1 && page.totalPageCount!=0}">
							<a href="JavaScript:up('${page.currentPageNo-1}')" id="nextpage" accesskey="n">上一页</a>&nbsp;
						</c:if>
						<c:if test="${page.currentPageNo!=page.totalPageCount && page.totalPageCount!=0}">
							<a href="JavaScript:down('${page.currentPageNo+1}')" id="nextpage" accesskey="n">下一页</a>&nbsp;
						</c:if>
						<input type="text" style="width:20px;" id="pageNo_up" name="pageNo"/><a href="javascript:skip();">跳转</a>
					</div>
					<div class="nowrap left">
						<input name="del" type="button" id="quick_del" class=" wd1 btn" value="删除" onclick="operatMailDetail(4,'')">
						<input type="button" id="quick_completelydel" class="wd3 btn" value="彻底删除" onclick="operatMailDetail(6,'')">
						<input type="button" class="mail_forward wd1 btn" value="转发" onclick="forwardingMail();">
						<input id="setAllReaded" type="button" class="wd4 btn" value="全部标为已读" onclick="operatMailDetail('',1)">
						<div id="markContainer" name="markContainer" style="float: left; width: 80px; margin: 2px 0 0 1px;">
							 <select id="mailsign" name="mailsign" onChange="operatSelectMailDetail(this,1)">
							 	<option value="">标记为...</option>
							 	<option value="1">已读标志</option>
							 	<option value="0">未读标志</option>
							 </select>
						</div>
						<div id="selmContainer" name="selmContainer" style="float: left; width: 80px; margin: 2px 6px 0 8px; _margin: 2px 0 0 1px;">
							 <select id="state" name="state" onChange="operatSelectMailDetail(this,2)">
							 	<option value="">移动到...</option>
							 	<option value="1">收件夹</option>
							 	<option value="2">草稿箱</option>
							 	<option value="3">已发送</option>
							 	<option value="4">已删除</option>
							 	<option value="5">垃圾邮件</option>
							 </select>
						</div>
					</div>
					<div class="clr">
						&nbsp;
					</div>
				</div>
				<table style="width:100%;" cellspacing="0" cellpadding="0"  class="O2">
					<tbody>
						<tr >
							<td width="5%">
								<input type="checkbox" onclick="check_all(this)" title="选中/取消选中">
							</td>
							<td width="10%">
								<c:choose>
							   		<c:when test="${tblMailDetail.state=='1' ||tblMailDetail.state=='4' ||tblMailDetail.state=='5'}">
										发件人
									</c:when>
							   		<c:when test="${tblMailDetail.state=='2' || tblMailDetail.state=='3'}">
							   			收件人
							   		</c:when>
						   		</c:choose>
							</td>
							<c:if test="${tblMailDetail.state=='1'}">
							<td width="10%">接收人</td>
							</c:if>
							<td width="30%">
								主题
							</td>
							<td width="10%">
								地区
							</td>
							<td width="10%">
								公司
							</td>
							<td width="10%">
								客户类型
							</td>
							<td class="o_title2">
								时间↓
							</td>
						</tr>
						<c:forEach items="${page.data}" var="data">
						<tr style="cursor:pointer;">
							<td style="background-color:white">
								<input type="checkbox" name='chk' value="${data.IDMAILDETAIL}">
								<c:if test="${data.IDMAILANNEX>0}"><img src="./index_files/icon_att0aa5d9.gif" /></c:if>
							</td>
							<td style="background-color:white;" onClick="queryMailInfo('${data.idMailDetail}')">
								<c:choose>
									<c:when
										test="${data.STATE=='1' ||data.STATE=='4' ||data.STATE=='5'}">
										<c:choose>
											<c:when test="${data.MAILSIGN=='1'}">${data.SENDPEOPLE}</c:when>
											<c:otherwise>
												<b>${data.SENDPEOPLE}</b>
											</c:otherwise>
										</c:choose>
									</c:when>
									<c:when test="${data.STATE=='2' || data.STATE=='3'}">
										<c:choose>
											<c:when test="${data.MAILSIGN=='1'}">${not empty data.RECPEOPLE?data.RECPEOPLE:'未填写'}</c:when>
											<c:otherwise>
												<b>${not empty data.RECPEOPLE?data.RECPEOPLE:'未填写'}</b>
											</c:otherwise>
										</c:choose>
									</c:when>
								</c:choose>
							</td>
							<c:if test="${tblMailDetail.state=='1'}">
							<td style="background-color:white;" onClick="queryMailInfo('${data.idMailDetail}')">
								${data.RECPEOPLE}
							</td>
							</c:if>
							<td style="background-color:white;" onClick="queryMailInfo('${data.idMailDetail}')">
								<c:choose>
									<c:when test="${data.MAILSIGN=='1'}">
										${data.TITLE}
									</c:when>
									<c:otherwise>
										<b>${data.TITLE}</b>
									</c:otherwise>
								</c:choose>
							</td>
							<td style="background-color:white" onClick="queryMailInfo('${data.idMailDetail}')">
								${data.IPCOUNTRY}
							</td>
							<td style="background-color:white" onClick="queryMailInfo('${data.idMailDetail}')">
								${data.IPCOMPANY}
							</td>
							<td style="background-color:white" onClick="queryMailInfo('${data.idMailDetail}')">
								${empty data.COMPANYTYPENAME?'陌生人':data.COMPANYTYPENAME}
							</td>
							<td style="background-color:white" onClick="queryMailInfo('${data.idMailDetail}')">${data.LASTDATE}</td>
						</tr>
						</c:forEach>
					</tbody>
				</table>
				<div class="list_btline">
					<div
						style="height: 19px; * height: 24px; padding-top: 5px; * padding-top: 3px"
						class="f_size selbar_bt barspace2">
						<span class="addrtitle">选择：</span>&nbsp;
						<a href="javascript:checkAll();" >全部</a>&nbsp;-&nbsp;
						<a href="javascript:checkNone();" >无</a>&nbsp;-&nbsp;
						<a href="javascript:checkRead(1);" >已读</a>&nbsp;-&nbsp;
						<a href="javascript:checkRead(0);" >未读</a>
					</div>
				</div>
				<div class="toolbg toolbgline toolheight nowrap" style="">
					<div class="right">
						${page.currentPageNo}/${page.totalPageCount}页&nbsp;
						<c:if test="${page.currentPageNo!=1 && page.totalPageCount!=0}">
							<a href="JavaScript:up('${page.currentPageNo-1}')" id="nextpage" accesskey="n">上一页</a>&nbsp;
						</c:if>
						<c:if test="${page.currentPageNo!=page.totalPageCount && page.totalPageCount!=0}">
							<a href="JavaScript:down('${page.currentPageNo+1}')" id="nextpage" accesskey="n">下一页</a>&nbsp;
						</c:if>
						<input type="text" style="width:20px;" id="pageNo_down" name="pageNo"/><a href="javascript:skip();">跳转</a>
					</div>
					<div class="nowrap left">
						<input name="del" type="button" id="quick_del" class=" wd1 btn" value="删除" onclick="operatMailDetail(4,'')">
						<input type="button" id="quick_completelydel" class="wd3 btn" value="彻底删除" onclick="operatMailDetail(6,'')">
						<input type="button" class="mail_forward wd1 btn" value="转发" onclick="forwardingMail();">
						<input id="setAllReaded" type="button" class="wd4 btn" value="全部标为已读" onclick="operatMailDetail('',1)">
						<div id="markContainer" name="markContainer" style="float: left; width: 80px; margin: 2px 0 0 1px;">
							 <select id="mailsign" name="mailsign" onChange="operatSelectMailDetail(this,1)">
							 	<option value="">标记为...</option>
							 	<option value="1">已读标志</option>
							 	<option value="0">未读标志</option>
							 </select>
						</div>
						<div id="selmContainer" name="selmContainer" style="float: left; width: 80px; margin: 2px 6px 0 8px; _margin: 2px 0 0 1px;">
							 <select id="state" name="state" onChange="operatSelectMailDetail(this,2)">
							 	<option value="">移动到...</option>
							 	<option value="1">收件夹</option>
							 	<option value="2">草稿箱</option>
							 	<option value="3">已发送</option>
							 	<option value="4">已删除</option>
							 	<option value="5">垃圾邮件</option>
							 </select>
						</div>
					</div>
					<div class="clr">
						&nbsp;
					</div>
				</div>
			</form>
		</div>
		<div class="attbg mysidebar" style="">
			<div class="bd b_size bold title_left">
				公司类型
				<input id="idCompanyType" type="hidden" name="idCompanyType" value="${idCompanyType}" />
				<input id="idCompany" type="hidden" name="idCompany" value="${idCompany}" />
			</div>
			<div class="bd b_size bold title_left">
				<select name="companyType" id="companyType" style="width:100%" onChange="queryPerson(this);">
					<option value="">请选择</option>
					<c:forEach items="${tblCompanyTypesList}" var="type" varStatus="order">
						<option value="${type.IDCOMPANYTYPE}" ${type.IDCOMPANYTYPE==idCompanyType?'selected':''}>${type.COMPANYTYPENAME}</option>	
					</c:forEach>
				</select>
			</div>
			<div class="bd b_size bold title_left">
				邮箱联系人
			</div>
			<div id="per">
				
			</div>
		</div>
	</div>
</body>
</html>